package com.example.test.service.责任连;

import com.example.test.service.责任连.实际执行者.执行1;
import com.example.test.service.责任连.实际执行者.执行2;
import com.example.test.service.责任连.实际执行者.执行3;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class FactoryAutoware implements ApplicationContextAware {

    private static Map<String,AbstractBean> map = new HashMap<>();

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        map.put("1",applicationContext.getBean(执行1.class));
        map.put("2",applicationContext.getBean(执行2.class));
        map.put("3",applicationContext.getBean(执行3.class));
    }

    public AbstractBean get(String type){
        return map.get(type);
    }
}
